package timing.jframe4l.api;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import timing.jframe4l.facade.model.Content;
import timing.jframe4l.facade.provider.ISysProvider;
import timing.jframe4l.web.base.AbstractController;
import timing.jframe4l.web.utils.WebUtil;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 内容表  前端控制器
 * </p>
 *
 * @author Fengxici
 * @since 2017-11-19
 */
@Controller
@RequestMapping("/content")
@Api(value = "内容表接口", description = "内容表接口")
public class ContentController extends AbstractController<ISysProvider> {
	public String getService() {
		return "contentService";
	}

	@RequiresPermissions("content.read")
	@PutMapping(value = "/read/list")
	@ApiOperation(value = "查询内容表", produces = MediaType.APPLICATION_JSON_VALUE)
	public Object query(HttpServletRequest request) {
		Map<String, Object> param = WebUtil.getParameter(request);
        ModelMap modelMap = new ModelMap();
		return super.query(modelMap, param);
	}

	@RequiresPermissions("content.read")
	@PutMapping(value = "/read/detail")
	@ApiOperation(value = "内容表详情", produces = MediaType.APPLICATION_JSON_VALUE)
	public Object get(HttpServletRequest request) {
		Content param = WebUtil.getParameter(request, Content.class);
        ModelMap modelMap = new ModelMap();
		return super.get(modelMap, param);
	}

	@PostMapping
	@RequiresPermissions("content.update")
	@ApiOperation(value = "修改内容表", produces = MediaType.APPLICATION_JSON_VALUE)
	public Object update(HttpServletRequest request) {
		Content param = WebUtil.getParameter(request, Content.class);
        ModelMap modelMap = new ModelMap();
		return super.update(modelMap, param);
	}

	@DeleteMapping
	@RequiresPermissions("content.delete")
	@ApiOperation(value = "删除内容表", produces = MediaType.APPLICATION_JSON_VALUE)
	public Object delete(HttpServletRequest request) {
		Content param = WebUtil.getParameter(request, Content.class);
        ModelMap modelMap = new ModelMap();
		return super.delete(modelMap, param);
	}
}